package net

import (
	"common/logs"
	"fmt"
	"io/ioutil"
	"net/http"
)

func AliyunHttpGetUrl(url, appcode, name, idcard string) []byte {
	client := &http.Client{}
	request, err := http.NewRequest("GET", url, nil)
	if err != nil {
		logs.Error("request.NewRequest,err=%v", err)
		return nil
	}
	request.Header.Add("Authorization", fmt.Sprintf("APPCODE %v", appcode))
	query := request.URL.Query()
	query.Add("idcard", idcard)
	query.Add("name", name)
	request.URL.RawQuery = query.Encode()
	res, err := client.Do(request)
	if err != nil {
		logs.Error("client.Do,err=%v", err)
		return nil
	}
	defer res.Body.Close()
	//服务端返回数据
	b, err := ioutil.ReadAll(res.Body)
	if err != nil {
		logs.Error("res.Body ioutil.ReadAll,err=%v", err)
		return nil
	}
	return b
}
